﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBLibrary;

public partial class pages_member_MemberOperation : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void DeleteCustomerImageButton_Click(object sender, ImageClickEventArgs e)
    {
        DB db = PoseidonDBHelper.UserDB;
        for (int i = 0; i <= this.SourceGridView.Rows.Count - 1; i++)
        {
            CheckBox cbox = (CheckBox)SourceGridView.Rows[i].FindControl("DeleteCheckBox");
            if (cbox.Checked)
            {
                db.Delete<CustomerDetail>(new DBParam("CustomerId", SourceGridView.DataKeys[i].Value));
            }
        }
        SourceGridView.DataBind();
    }

    protected void SourceGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("ModifyDetail", StringComparison.OrdinalIgnoreCase))
        {
            this.Response.Redirect(string.Format("~/pages/member/AddNewMember.aspx?action=m&id={0}", e.CommandArgument));
        }
        else if (e.CommandName.Equals("ViewDetail", StringComparison.OrdinalIgnoreCase))
        {
            this.Response.Redirect(string.Format("~/pages/member/CustomerDetailPage.aspx?action=v&id={0}", e.CommandArgument));
        }
    }
}